local skill = fk.CreateSkill {
  name = "#lvshi__yitian_sword_skill",
  attached_equip = "lvshi__yitian_sword",
}

Fk:loadTranslationTable{
  ["#lvshi__yitian-invoke"] = "你可将此【杀】视为光【杀】",
  ["#lvshi__yitian_sword_throw"] = "倚天剑：你可弃置一张手牌，回复1点体力",
}

skill:addEffect(fk.AfterCardUseDeclared, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skill.name) and data.card.trueName == "slash"
    and data.card.name ~= "slash" and data.card.name ~= "lvshi__slash" and data.card.name ~= "bright__slash"
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#lvshi__yitian-invoke")
  end,
  on_use = function(self, event, target, player, data)
    data:changeCard("bright__slash", data.card.suit, data.card.number, skill.name)
  end,
})

skill:addEffect(fk.Damage, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skill.name) and data.damageType == fk.BrightDamage
    and player:isWounded()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local card = room:askToDiscard(player, {
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = skill.name,
      cancelable = true,
      prompt = "#lvshi__yitian_sword_throw",
    })
    if #card > 0 then
      event:setCostData(self, {cards = card})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    --room:throwCard(event:getCostData(self).cards, skill.name, player, player)
    room:recover{
      who = player,
      num = 1,
      recoverBy = player,
      skillName = skill.name,
    }
  end,
})

return skill